﻿using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Text;

namespace Infrastructure.Cache
{
    public class MemoryCacheService : IMemoryCacheService
    {
        public static IMemoryCache _memoryCache = new MemoryCache(new MemoryCacheOptions());

        public void Del(string key)
        {
            _memoryCache.Remove(key);
        }

        public T Get<T>(string key)
        {
            return _memoryCache.Get<T>(key);
        }
        public void Set<T>(string key, T t)
        {

            _memoryCache.Set<T>(key, t);
        }
        public void Set<T>(string key, T t, TimeSpan time)
        {

            _memoryCache.Set<T>(key, t, DateTime.Now.Add(time));
        }
    }
}
